﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using A2DFramework.InstanceService;
using A2DFramework.EsbService.NativeEsb;
using A2DFramework.EsbService.DistributedEsb;

namespace A2DFramework.EsbService
{
    public static class Starter
    {
        public static void Init()
        {
            XElement root = XElement.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "A2D.config"));
            if (root.Element("EsbSetting") != null)
            {
                if (root.Element("EsbSetting").Attribute("BusType").Value == "Native")
                    ObjectFactory.RegisterAsSingleton<IEsb, NativeEsbImpl>();
                else if (root.Element("EsbSetting").Attribute("BusType").Value == "DistributedEsb")
                    ObjectFactory.RegisterAsSingleton<IEsb, DistributedEsbImpl>();
            }
        }
    }
}
